package com.woniuxy.businessassembly.service.impl;

import com.woniuxy.businessassembly.model.HotelInfo;
import com.woniuxy.businessassembly.model.HotelPolicy;
import com.woniuxy.businessassembly.dao.HotelPolicyMapper;
import com.woniuxy.businessassembly.service.IHotelPolicyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.hotel.form.PolicyForm;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Kevin Kwok
 * @since 2021-05-24
 */
@Service
public class HotelPolicyServiceImpl extends ServiceImpl<HotelPolicyMapper, HotelPolicy> implements IHotelPolicyService {
    @Resource
    private HotelPolicyMapper policyMapper;
    @Override
    public int addHotelPolicy(PolicyForm policyForm) {
        /*给指定的酒店发布酒店政策*/
        int i = policyMapper.publishPolicy(policyForm);
        return i;
    }

    @Override
    public HotelPolicy queryPolicyHotel(String hotelName) {
        int i = 0;
        /*根据酒店名查询酒店的id*/
        HotelInfo hotelInfo = policyMapper.queryByName(hotelName);
        if(hotelInfo!=null){
            Integer hotelId = hotelInfo.getHotelId();
            HotelPolicy hotelPolicy = policyMapper.queryPolicy(hotelId);
            return hotelPolicy;
        }
        return null;
    }

    @Override
    public int modifyPolicyHotel(HotelPolicy hotelPolicy) {
        int i = policyMapper.modifyPolicy(hotelPolicy);
        return i;
    }
}
